#pragma once
#ifndef PLAYER_UI_DELEGATE_UTIL_INCLUDE_H_
#define PLAYER_UI_DELEGATE_UTIL_INCLUDE_H_

#include <functional>
#include "uilib/uilib.h"
#include "uilib/uibase.h"
#include "uilib/UIDelegate.h"

namespace DuiLib {

typedef std::function<bool(void* param)> InvokeFuncStorage;

class CDlegateParam : public CDelegateBase {
public:
	CDlegateParam(InvokeFuncStorage invoke) 
		: CDelegateBase(NULL, NULL) {
		invoke_func = invoke;
	}

	CDlegateParam(const CDlegateParam& rhs) 
		: CDelegateBase(rhs) { 
		invoke_func = rhs.invoke_func;
	}

	virtual ~CDlegateParam() {}

	virtual CDelegateBase* Copy() { 
		return new CDlegateParam(*this); 
	}
	
protected:
	virtual bool Invoke(void* param) {
		return invoke_func(param);
	}

protected:
	InvokeFuncStorage invoke_func;
};

inline CDlegateParam MakeDelegate(InvokeFuncStorage invoke) {
	return CDlegateParam(invoke);
}

}

#endif	// !defined(PLAYER_UI_DELEGATE_UTIL_INCLUDE_H_)